<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<script src="js/mui.min.js"></script>
		<link href="css/mui.min.css" rel="stylesheet" />
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
		<style>
			button {
				display: block;
				margin-top: 10px;
				margin-bottom: 10px;
				margin-left: 20px;
				width: 40%;
			}
		</style>
	</head>

	<body>

		<div style="width: 100%;">
			<button onclick="sendMsg()" style="text-align: center;">send all</button>

			<button onclick="jump('sub1.html','sub1.html')">sub1</button>
		</div>

		<ul  class="mui-table-view">
			<li class="mui-table-view-cell mui-collapse">
				<img id="img1" width="70%"/>
			</li>
		</ul>

		<script src="js/ni.js"></script>
		<script>
			var broadcast = new ni.Broadcast()
			ni.ready(function() {
				console.log('ni ready')
			})
			ni.plusReady(function() {
				console.log('ni plusReady')
				// 删除之前say事件
				broadcast.off('say')
				// 监听say事件
				broadcast.on('say', function(data) {
					alert("【index.html】:" + JSON.stringify(data))
				})

				broadcast.on('b1', function(data) {
					alert("【index.html】:" + JSON.stringify(data))
					document.getElementById("img1").src="http://p0.so.qhimgs1.com/bdr/326__/t01acd9418fe37ffacc.jpg";
				})

			})

			/**
			 * 页面通知
			 */
			function sendMsg() {
				// 发送say事件
				broadcast.emit('say', {
					name: 'Ni Hao'
				}, {
					self: true, // 是否通知当前页面  默认不通知
					//ids: [] // 通知特定id的webview, 默认为全部
				})
			}

			function jump(pageId, url) {
				mui.openWindow({
					url: url,
					id: pageId,
					show: {
						autoShow: true,
						duration: 200
					}
				})
			};
		</script>
	</body>

</html>